package com.ServletDemo.servletText02;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;


@WebServlet("/servletDemo03")
public class servletDemo03 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        String username = req.getParameter("username");
        String age = req.getParameter("age");
        String score = req.getParameter("score");
        System.out.println(username+","+Integer.parseInt(age)+","+Integer.parseInt(score));

        System.out.println("==================");

        String[] usernames = req.getParameterValues("username");
        String[] ages = req.getParameterValues("age");
        String[] scores = req.getParameterValues("score");
        System.out.println(Arrays.toString(usernames)+","+Arrays.toString(ages)+","+Arrays.toString(scores));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
